<template>
	<view>
		<view class="header status_bar" :class="scrrol == true ? 'scrrolHeader' : ''">
			<view class="back iconfont" @tap="backPage">&#xe779;</view>
			<view class="text">账户盈利</view>
		</view>

		<view class="bg_box">
			<image class="bg01" :src="'https://cxh-imgs.oss-cn-shanghai.aliyuncs.com/static/' + 'bg05.png'"
				mode="widthFix"></image>
			<view class="balance_content">
				<view class="balance_box">
					<view class="title">可提现金额(元)</view>
					<view class="num">{{ info.cashing_money }}</view>
					<view class="confirm02" :data-url="'/pages/personalcenter/carry?money=' + info.cashing_money"
						@click="gotopage">提现</view>
				</view>

				<view class="menu_box">
					<view class="menu">
						<view class="num">{{info.delivery_num}}</view>
						<view class="text">取件单量</view>
					</view>
					<view class="menu" :data-url="'/pages/personalcenter/list?type=' + 0" @click="gotopage">
						<view class="num">{{info.delivery_coupon_num}}</view>
						<view class="text">取件劵量</view>
					</view>
					<view class="menu">
						<view class="num">{{info.delivery_owner}}</view>
						<view class="text">取件收入</view>
					</view>
					<!-- <view class="menu">
						<view class="num">{{info.delivery_money}}</view>
						<view class="text">会费总额</view>
					</view> -->
				</view>
				<view class="menu_box">
					<view class="menu">
						<view class="num">{{info.send_num}}</view>
						<view class="text">寄件单量</view>
					</view>
					<view class="menu" :data-url="'/pages/personalcenter/list?type=' + 2" @click="gotopage">
						<view class="num">{{info.send_coupon_num}}</view>
						<view class="text">寄件劵量</view>
					</view>
					<view class="menu">
						<view class="num">{{info.send_owner}}</view>
						<view class="text">寄件收入</view>
					</view>
					
				</view>
				<view class="menu_box">
					<view class="menu">
						<view class="num">{{info.waste_num}}</view>
						<view class="text">服务单量</view>
					</view>
					<view class="menu" :data-url="'/pages/personalcenter/list?type=' + 1" @click="gotopage">
						<view class="num">{{info.waste_coupon_num}}</view>
						<view class="text">服务劵量</view>
					</view>
					<view class="menu">
						<view class="num">{{info.waste_money}}</view>
						<view class="text">服务收入</view>
					</view>
					<!-- <view class="menu">
						<view class="num">{{info.goods_order}}</view>
						<view class="text">商品订单</view>
					</view> -->
				</view>

				<view class="detailed_box">
					<view class="title">账户明细</view>
					<block v-for="(item, index) in list" :key="'list' + index">
						<view class="list">
							<view class="text_box">
								<view class="title02">{{item.name}}</view>
								<view class="time">{{ item.created_at }}</view>
							</view>
							<view class="money" :class="item.type == 1 ? 'moneycolor' : ''">￥{{ item.money }}</view>
						</view>
					</block>
				</view>
			</view>
		</view>




	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				list: [],
				info: '',
				money: '',
				scrrol: false,
			};
		},
		onLoad(options) {
			let that = this;
			that.money = options.money;
		},
		onShow() {
			let that = this;
			that.page = 1;
			that.loadData();
			that.balanceData();
		},
		methods: {
			backPage() {
				uni.navigateBack({});
			},
			gotopage(e) {
				let url = e.currentTarget.dataset.url;
				uni.navigateTo({
					url: url
				});
			},
			loadData() {
				let that = this;
				that.Net._get('terminal/revenue_source', {}, res => {
					if (res.code == 200) {
						that.info = res.data;
					}
				});
			},
			// 明细列表
			balanceData() {
				let that = this;
				that.Net._get('terminal/money_logs', {
					per_page: '10',
					page: that.page
				}, res => {
					if (res.code == 200) {
						//console.log(res)
						that.list = res.data.list.data;
					}
				});
			},
		},
		onReachBottom() {
			var that = this;
			that.page++;
			that.Net._get('terminal/money_logs', {
				per_page: '10',
				page: that.page
			}, res => {
				if (res.code == 200) {
					if (res.data.list.data == '') {
						uni.showToast({
							title: '已经是最后一页了',
							duration: 2000,
							icon: 'none'
						});
					} else {
						that.list = that.list.concat(res.data.list.data); //将数据拼接在一起
					}
				} else if (res.code == 0) {
					that.Msg.Success(res.msg, res => {});
				}
			});
		},

		onPullDownRefresh() {
			//监听下拉刷新动作的执行方法，每次手动下拉刷新都会执行一次
			let that = this;
			that.page = 1;
			that.info = [];
			that.list = [];
			setTimeout(function() {
				uni.stopPullDownRefresh();
				that.loadData();
				that.balanceData();
			}, 500);
		},
		onPageScroll: function(Object) {
			//console.log(Object.scrollTop); //实时获取到滚动的值
			if (Object.scrollTop > 28) {
				this.scrrol = true;
				/* #ifdef APP-PLUS */
				/* #endif */
			} else if (Object.scrollTop < 28) {
				this.scrrol = false;
				/* #ifdef APP-PLUS */
				/* #endif */
			}
		}
	};
</script>

<style>
	.scrrolHeader {
		background-color: #fef2e6 !important;
	}

	.header {
		background-color: transparent;
	}

	.header .text {
		background-color: transparent;
		color: #333;
	}

	.header .back {
		color: #333;
	}

	.bg_box {
		width: 100%;
		position: relative;
	}

	.bg_box .bg01 {
		width: 100%;
		display: block;
	}

	.bg_box .balance_content {
		width: 92%;
		position: absolute;
		left: calc(50% - 46%);
		top: calc(20vw + var(--status-bar-height));
		z-index: 97;
	}

	.bg_box .balance_content .balance_box {
		width: 100%;
		background-color: #fff;
		border-radius: 2vw;
		padding: 3vw;
	}

	.bg_box .balance_content .balance_box .title {
		font-size: 3.5vw;
		color: #333333;
		margin-top: 10vw;
		text-align: center;
	}

	.bg_box .balance_content .balance_box .num {
		font-size: 8vw;
		color: #333333;
		margin-top: 3vw;
		font-weight: bold;
		text-align: center;
	}

	.confirm02 {
		width: 100%;
		border-radius: 2vw;
		margin-top: 10vw;
	}

	.detailed_box {
		width: 100%;
		background-color: #fff;
		border-radius: 2vw;
		padding: 0 3vw 3vw 3vw;
		margin-top: 4%;
	}

	.detailed_box .title {
		font-size: 4vw;
		font-weight: bold;
		color: #333333;
		height: 13vw;
		line-height: 13vw;
		border-bottom: 1px solid #ECECEC;
	}

	.detailed_box .list {
		width: 100%;
		margin: 0 auto;
		padding: 3vw 0;
		display: flex;
	}

	.detailed_box .list .money {
		flex: 1;
		font-size: 4vw;
		font-weight: bold;
		color: #333;
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}

	.detailed_box .list .text_box {
		flex: 1;
	}

	.detailed_box .list .text_box .title02 {
		font-size: 3.5vw;
		color: #333;
		font-weight: bold;
	}

	.detailed_box .list .text_box .time {
		font-size: 3vw;
		color: #999;
		margin-top: 1vw;
	}

	.moneycolor {
		color: #f00 !important;
	}

	.menu_box {
		width: 100%;
		margin: 0 auto;
		display: flex;
		padding: 3vw 0;
		border-radius: 2vw;
		margin-top: 3vw;
		background-color: #fff;
	}

	.menu_box .menu {
		flex: 1;
	}

	.menu_box .menu .num {
		font-size: 5vw;
		font-weight: bold;
		color: #1d1f24;
		text-align: center;
	}

	.menu_box .menu .text {
		font-size: 3.2vw;
		color: #757880;
		text-align: center;
		margin-top: 1vw;
	}
</style>
